<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UC-QA-002：语音识别原型</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/antd@5.12.8/dist/reset.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'PingFang SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background-color: #f5f5f5;
            color: #333;
        }
        
        .header {
            background: #fff;
            padding: 16px 24px;
            border-bottom: 1px solid #e8e8e8;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .breadcrumb {
            color: #666;
            font-size: 14px;
        }
        
        .breadcrumb a {
            color: #1890ff;
            text-decoration: none;
        }
        
        .main-content {
            padding: 24px;
            max-width: 1400px;
            margin: 0 auto;
        }
        
        .content-area {
            display: grid;
            grid-template-columns: 240px 1fr;
            gap: 24px;
        }
        
        .sidebar {
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            overflow: hidden;
        }
        
        .sidebar-header {
            background: #fafafa;
            padding: 16px 20px;
            border-bottom: 1px solid #e8e8e8;
        }
        
        .sidebar-title {
            font-size: 16px;
            font-weight: 600;
            color: #333;
        }
        
        .sidebar-content {
            padding: 16px;
        }
        
        .history-list {
            list-style: none;
            margin-bottom: 24px;
        }
        
        .history-item {
            padding: 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.3s;
            margin-bottom: 8px;
            border: 1px solid #f0f0f0;
        }
        
        .history-item:hover {
            background: #f8f9fa;
            border-color: #1890ff;
        }
        
        .history-item.active {
            background: #e6f7ff;
            border-color: #1890ff;
        }
        
        .history-time {
            font-size: 11px;
            color: #999;
            margin-bottom: 4px;
        }
        
        .history-text {
            font-size: 12px;
            color: #333;
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }
        
        .history-language {
            font-size: 10px;
            color: #666;
            margin-top: 4px;
        }
        
        .settings-options {
            list-style: none;
        }
        
        .settings-item {
            padding: 8px 0;
            cursor: pointer;
            font-size: 13px;
            color: #666;
            transition: color 0.3s;
        }
        
        .settings-item:hover {
            color: #1890ff;
        }
        
        .main-panel {
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            overflow: hidden;
        }
        
        .panel-header {
            background: #fafafa;
            padding: 16px 20px;
            border-bottom: 1px solid #e8e8e8;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .panel-title {
            font-size: 16px;
            font-weight: 600;
            color: #333;
        }
        
        .status-indicator {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #52c41a;
        }
        
        .status-text {
            font-size: 12px;
            color: #666;
        }
        
        .panel-content {
            padding: 24px;
        }
        
        .voice-input-section {
            background: #f8f9fa;
            border-radius: 12px;
            padding: 40px;
            text-align: center;
            margin-bottom: 24px;
            border: 2px dashed #d9d9d9;
            transition: all 0.3s;
            cursor: pointer;
        }
        
        .voice-input-section:hover {
            border-color: #1890ff;
            background: #f0f8ff;
        }
        
        .voice-input-section.recording {
            border-color: #ff4d4f;
            background: #fff2f0;
        }
        
        .voice-icon {
            font-size: 64px;
            margin-bottom: 16px;
            color: #1890ff;
            transition: all 0.3s;
        }
        
        .voice-input-section.recording .voice-icon {
            color: #ff4d4f;
            animation: pulse 1.5s infinite;
        }
        
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }
        
        .voice-text {
            font-size: 18px;
            color: #333;
            margin-bottom: 8px;
        }
        
        .voice-hint {
            font-size: 14px;
            color: #666;
        }
        
        .audio-visualization {
            margin: 20px 0;
            height: 60px;
            background: #f0f0f0;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }
        
        .waveform {
            display: flex;
            align-items: center;
            gap: 2px;
            height: 100%;
        }
        
        .wave-bar {
            width: 3px;
            background: #1890ff;
            border-radius: 2px;
            animation: wave 1s ease-in-out infinite;
        }
        
        .wave-bar:nth-child(2) { animation-delay: 0.1s; }
        .wave-bar:nth-child(3) { animation-delay: 0.2s; }
        .wave-bar:nth-child(4) { animation-delay: 0.3s; }
        .wave-bar:nth-child(5) { animation-delay: 0.4s; }
        .wave-bar:nth-child(6) { animation-delay: 0.5s; }
        .wave-bar:nth-child(7) { animation-delay: 0.6s; }
        .wave-bar:nth-child(8) { animation-delay: 0.7s; }
        .wave-bar:nth-child(9) { animation-delay: 0.8s; }
        .wave-bar:nth-child(10) { animation-delay: 0.9s; }
        
        @keyframes wave {
            0%, 100% { height: 20%; }
            50% { height: 80%; }
        }
        
        .recognition-result {
            background: #f6ffed;
            border: 1px solid #b7eb8f;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 24px;
        }
        
        .result-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }
        
        .result-title {
            font-size: 14px;
            font-weight: 600;
            color: #52c41a;
        }
        
        .confidence-score {
            font-size: 12px;
            color: #666;
        }
        
        .result-text {
            font-size: 16px;
            line-height: 1.6;
            color: #333;
            margin-bottom: 12px;
        }
        
        .result-actions {
            display: flex;
            gap: 8px;
        }
        
        .btn {
            padding: 6px 12px;
            border: 1px solid;
            border-radius: 4px;
            font-size: 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
            transition: all 0.3s;
        }
        
        .btn-primary {
            background: #1890ff;
            border-color: #1890ff;
            color: #fff;
        }
        
        .btn-primary:hover {
            background: #40a9ff;
            border-color: #40a9ff;
        }
        
        .btn-default {
            background: #fff;
            border-color: #d9d9d9;
            color: #333;
        }
        
        .btn-default:hover {
            border-color: #1890ff;
            color: #1890ff;
        }
        
        .control-panel {
            background: #f8f9fa;
            border-radius: 8px;
            padding: 20px;
        }
        
        .control-buttons {
            display: flex;
            gap: 12px;
            margin-bottom: 20px;
        }
        
        .btn-large {
            padding: 12px 24px;
            font-size: 14px;
            flex: 1;
        }
        
        .parameter-settings {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 16px;
        }
        
        .setting-item {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        
        .setting-label {
            font-size: 13px;
            color: #333;
            font-weight: 500;
        }
        
        .setting-control {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .setting-control select {
            flex: 1;
            padding: 6px 8px;
            border: 1px solid #d9d9d9;
            border-radius: 4px;
            font-size: 12px;
        }
        
        .setting-control input[type="range"] {
            flex: 1;
        }
        
        .setting-value {
            font-size: 11px;
            color: #666;
            min-width: 30px;
        }
        
        .modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        
        .modal-content {
            background: #fff;
            border-radius: 8px;
            padding: 24px;
            max-width: 500px;
            width: 90%;
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }
        
        .modal-title {
            font-size: 18px;
            font-weight: 600;
            color: #333;
        }
        
        .modal-close {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            color: #999;
        }
        
        .modal-footer {
            display: flex;
            justify-content: flex-end;
            gap: 12px;
            margin-top: 20px;
        }
        
        @media (max-width: 768px) {
            .content-area {
                grid-template-columns: 1fr;
            }
            
            .sidebar {
                order: -1;
            }
            
            .parameter-settings {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <!-- 页面头部 -->
    <div class="header">
        <div class="breadcrumb">
            <a href="#">首页</a> > <a href="#">语音服务</a> > 语音识别
        </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="main-content">
        <div class="content-area">
            <!-- 侧边栏 -->
            <div class="sidebar">
                <div class="sidebar-header">
                    <div class="sidebar-title">识别历史</div>
                </div>
                <div class="sidebar-content">
                    <ul class="history-list">
                        <li class="history-item active" onclick="selectHistory(this)">
                            <div class="history-time">2024-05-15 14:30</div>
                            <div class="history-text">请听下面的问题，然后通过语音回答：在完成操作后，应该进行哪些检查步骤？</div>
                            <div class="history-language">中文</div>
                        </li>
                        <li class="history-item" onclick="selectHistory(this)">
                            <div class="history-time">2024-05-15 14:25</div>
                            <div class="history-text">操作前必须佩戴安全防护用品，确保工作环境安全。</div>
                            <div class="history-language">中文</div>
                        </li>
                        <li class="history-item" onclick="selectHistory(this)">
                            <div class="history-time">2024-05-15 14:20</div>
                            <div class="history-text">按照标准操作流程开始执行任务，注意观察关键节点。</div>
                            <div class="history-language">中文</div>
                        </li>
                        <li class="history-item" onclick="selectHistory(this)">
                            <div class="history-time">2024-05-15 14:15</div>
                            <div class="history-text">Welcome to the training course. Please follow the safety procedures.</div>
                            <div class="history-language">英文</div>
                        </li>
                    </ul>
                    
                    <div style="margin-bottom: 20px;">
                        <div class="sidebar-title" style="margin-bottom: 12px;">设置选项</div>
                        <ul class="settings-options">
                            <li class="settings-item" onclick="openSettings()">⚙️ 识别设置</li>
                            <li class="settings-item" onclick="openHelp()">❓ 使用帮助</li>
                            <li class="settings-item" onclick="openAbout()">ℹ️ 关于</li>
                            <li class="settings-item" onclick="clearHistory()">🗑️ 清空历史</li>
                        </ul>
                    </div>
                </div>
            </div>

            <!-- 主面板 -->
            <div class="main-panel">
                <div class="panel-header">
                    <div class="panel-title">语音识别</div>
                    <div class="status-indicator">
                        <div class="status-dot"></div>
                        <span class="status-text">服务正常</span>
                    </div>
                </div>
                
                <div class="panel-content">
                    <!-- 语音输入区域 -->
                    <div class="voice-input-section" id="voiceInput" onclick="toggleRecording()">
                        <div class="voice-icon" id="voiceIcon">🎤</div>
                        <div class="voice-text" id="voiceText">点击开始录音</div>
                        <div class="voice-hint">请清晰地说出您要识别的内容</div>
                    </div>
                    
                    <!-- 音频可视化 -->
                    <div class="audio-visualization" id="audioVisualization" style="display: none;">
                        <div class="waveform">
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                            <div class="wave-bar"></div>
                        </div>
                    </div>
                    
                    <!-- 识别结果 -->
                    <div class="recognition-result" id="recognitionResult" style="display: none;">
                        <div class="result-header">
                            <div class="result-title">识别结果</div>
                            <div class="confidence-score">置信度: 95%</div>
                        </div>
                        <div class="result-text" id="recognizedText">
                            在完成操作后，应该进行以下检查步骤：1. 检查设备状态是否正常；2. 确认所有工具已归位；3. 清理工作区域；4. 记录操作日志。
                        </div>
                        <div class="result-actions">
                            <button class="btn btn-primary" onclick="editResult()">✏️ 编辑</button>
                            <button class="btn btn-default" onclick="copyResult()">📋 复制</button>
                            <button class="btn btn-default" onclick="saveResult()">💾 保存</button>
                            <button class="btn btn-default" onclick="clearResult()">🗑️ 清除</button>
                        </div>
                    </div>
                    
                    <!-- 控制面板 -->
                    <div class="control-panel">
                        <div class="control-buttons">
                            <button class="btn btn-primary btn-large" onclick="startRecording()" id="startBtn">🎤 开始录音</button>
                            <button class="btn btn-default btn-large" onclick="stopRecording()" id="stopBtn" disabled>⏹️ 停止录音</button>
                            <button class="btn btn-default btn-large" onclick="pauseRecording()" id="pauseBtn" disabled>⏸️ 暂停录音</button>
                            <button class="btn btn-default btn-large" onclick="clearAll()">🗑️ 清除全部</button>
                        </div>
                        
                        <div class="parameter-settings">
                            <div class="setting-item">
                                <div class="setting-label">识别语言</div>
                                <div class="setting-control">
                                    <select id="languageSelect">
                                        <option value="zh-CN" selected>中文</option>
                                        <option value="en-US">英文</option>
                                        <option value="vi-VN">越南语</option>
                                    </select>
                                </div>
                            </div>
                            
                            <div class="setting-item">
                                <div class="setting-label">置信度阈值</div>
                                <div class="setting-control">
                                    <input type="range" min="0" max="100" value="80" id="confidenceSlider">
                                    <span class="setting-value" id="confidenceValue">80%</span>
                                </div>
                            </div>
                            
                            <div class="setting-item">
                                <div class="setting-label">标点符号</div>
                                <div class="setting-control">
                                    <input type="checkbox" id="punctuationCheck" checked>
                                    <label for="punctuationCheck">启用标点符号</label>
                                </div>
                            </div>
                            
                            <div class="setting-item">
                                <div class="setting-label">语法检查</div>
                                <div class="setting-control">
                                    <input type="checkbox" id="grammarCheck">
                                    <label for="grammarCheck">启用语法检查</label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 设置弹窗 -->
    <div class="modal" id="settingsModal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title">识别设置</h3>
                <button class="modal-close" onclick="closeModal()">&times;</button>
            </div>
            <div class="modal-body">
                <div style="margin-bottom: 16px;">
                    <label style="display: block; margin-bottom: 8px; font-weight: 500;">音频质量</label>
                    <select style="width: 100%; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px;">
                        <option value="high" selected>高质量</option>
                        <option value="medium">中等质量</option>
                        <option value="low">低质量</option>
                    </select>
                </div>
                <div style="margin-bottom: 16px;">
                    <label style="display: block; margin-bottom: 8px; font-weight: 500;">采样率</label>
                    <select style="width: 100%; padding: 8px; border: 1px solid #d9d9d9; border-radius: 4px;">
                        <option value="16000" selected>16kHz</option>
                        <option value="44100">44.1kHz</option>
                        <option value="48000">48kHz</option>
                    </select>
                </div>
                <div style="margin-bottom: 16px;">
                    <label style="display: block; margin-bottom: 8px; font-weight: 500;">噪音抑制</label>
                    <input type="checkbox" checked> 启用噪音抑制
                </div>
                <div>
                    <label style="display: block; margin-bottom: 8px; font-weight: 500;">自动保存</label>
                    <input type="checkbox" checked> 自动保存识别结果
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" onclick="closeModal()">取消</button>
                <button class="btn btn-primary" onclick="saveSettings()">保存</button>
            </div>
        </div>
    </div>

    <script>
        // 全局变量
        let isRecording = false;
        let isPaused = false;

        // 录音控制
        function toggleRecording() {
            if (isRecording) {
                stopRecording();
            } else {
                startRecording();
            }
        }

        function startRecording() {
            isRecording = true;
            isPaused = false;
            
            const voiceInput = document.getElementById('voiceInput');
            const voiceIcon = document.getElementById('voiceIcon');
            const voiceText = document.getElementById('voiceText');
            const audioVisualization = document.getElementById('audioVisualization');
            const startBtn = document.getElementById('startBtn');
            const stopBtn = document.getElementById('stopBtn');
            const pauseBtn = document.getElementById('pauseBtn');
            
            voiceInput.classList.add('recording');
            voiceIcon.textContent = '🔴';
            voiceText.textContent = '正在录音...';
            audioVisualization.style.display = 'flex';
            
            startBtn.disabled = true;
            stopBtn.disabled = false;
            pauseBtn.disabled = false;
            
            console.log('开始录音');
        }

        function stopRecording() {
            isRecording = false;
            isPaused = false;
            
            const voiceInput = document.getElementById('voiceInput');
            const voiceIcon = document.getElementById('voiceIcon');
            const voiceText = document.getElementById('voiceText');
            const audioVisualization = document.getElementById('audioVisualization');
            const recognitionResult = document.getElementById('recognitionResult');
            const startBtn = document.getElementById('startBtn');
            const stopBtn = document.getElementById('stopBtn');
            const pauseBtn = document.getElementById('pauseBtn');
            
            voiceInput.classList.remove('recording');
            voiceIcon.textContent = '🎤';
            voiceText.textContent = '点击开始录音';
            audioVisualization.style.display = 'none';
            recognitionResult.style.display = 'block';
            
            startBtn.disabled = false;
            stopBtn.disabled = true;
            pauseBtn.disabled = true;
            
            console.log('停止录音');
        }

        function pauseRecording() {
            isPaused = !isPaused;
            
            const voiceText = document.getElementById('voiceText');
            const pauseBtn = document.getElementById('pauseBtn');
            
            if (isPaused) {
                voiceText.textContent = '录音已暂停...';
                pauseBtn.textContent = '▶️ 继续录音';
            } else {
                voiceText.textContent = '正在录音...';
                pauseBtn.textContent = '⏸️ 暂停录音';
            }
            
            console.log('暂停/继续录音');
        }

        function clearAll() {
            const recognitionResult = document.getElementById('recognitionResult');
            const voiceInput = document.getElementById('voiceInput');
            const voiceIcon = document.getElementById('voiceIcon');
            const voiceText = document.getElementById('voiceText');
            
            recognitionResult.style.display = 'none';
            voiceInput.classList.remove('recording');
            voiceIcon.textContent = '🎤';
            voiceText.textContent = '点击开始录音';
            
            console.log('清除全部');
        }

        // 结果操作
        function editResult() {
            console.log('编辑结果');
        }

        function copyResult() {
            const text = document.getElementById('recognizedText').textContent;
            navigator.clipboard.writeText(text);
            console.log('复制结果');
        }

        function saveResult() {
            console.log('保存结果');
        }

        function clearResult() {
            const recognitionResult = document.getElementById('recognitionResult');
            recognitionResult.style.display = 'none';
            console.log('清除结果');
        }

        // 历史记录
        function selectHistory(element) {
            document.querySelectorAll('.history-item').forEach(item => {
                item.classList.remove('active');
            });
            element.classList.add('active');
            
            const text = element.querySelector('.history-text').textContent;
            document.getElementById('recognizedText').textContent = text;
            document.getElementById('recognitionResult').style.display = 'block';
            
            console.log('选择历史记录');
        }

        // 设置
        function openSettings() {
            document.getElementById('settingsModal').style.display = 'flex';
        }

        function openHelp() {
            console.log('打开帮助');
        }

        function openAbout() {
            console.log('打开关于');
        }

        function clearHistory() {
            if (confirm('确定要清空所有历史记录吗？')) {
                console.log('清空历史记录');
            }
        }

        function saveSettings() {
            closeModal();
            console.log('保存设置');
        }

        // 弹窗控制
        function closeModal() {
            document.getElementById('settingsModal').style.display = 'none';
        }

        // 点击弹窗外部关闭
        document.getElementById('settingsModal').addEventListener('click', (e) => {
            if (e.target.id === 'settingsModal') {
                closeModal();
            }
        });

        // 参数控制
        document.getElementById('confidenceSlider').addEventListener('input', (e) => {
            document.getElementById('confidenceValue').textContent = e.target.value + '%';
        });

        // 语言切换
        document.getElementById('languageSelect').addEventListener('change', (e) => {
            console.log('切换语言:', e.target.value);
        });

        // 初始化
        document.addEventListener('DOMContentLoaded', () => {
            console.log('语音识别页面初始化');
        });
    </script>
</body>
</html>

